package com.example.demo;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;


@RequestMapping("/response")
@Controller
public class ResponseController {
    @RequestMapping("p1")
    public String responseHtml(){
        return "/hello.html";
    }
    @RequestMapping("p2")
    @ResponseBody
    public String response1(){
        return "hahahahaha";
    }
    @RequestMapping("p3")
    @ResponseBody
    public String response2(){
        return "<h1>欢迎</h1>";
    }
    @ResponseBody
    @RequestMapping("p4")
    public Person responseJSON(){
        Person person=new Person();
        person.setName("zhangsan");
        person.setId(111);
        person.setPassword("abc123");
        return person;
    }
    @RequestMapping("p5")
    @ResponseBody
    public String setHeader(HttpServletResponse response){
        response.setHeader("java","112");
        return "success";
    }
}
